package com.example.bbook.controller;

import com.example.bbook.services.DashboardService;
import com.example.bbook.util.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("/dashboard")
public class DashboardController {
    @Autowired
    private DashboardService dashboardService;

    @RequestMapping("/rankList")
    public Response getMaxNumGoods() {
        return Response.successful(dashboardService.getRankList());
    }

    @RequestMapping("/goodsTypeNum")
    public Response getGoodsTypeNum() {
        return Response.successful(dashboardService.getGoodsTypeNum());
    }

    @RequestMapping("/goodsTypeMoney")
    public Response getGoodsTypeMoney() {
        return Response.successful(dashboardService.getSalesMoney());
    }

    @RequestMapping("/goodsRank")
    public Response getGoodsRank() {
        return Response.successful(dashboardService.getGoodsRank());
    }
}
